# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: team/gnome <ablocorrea@hotmail.com>
pkgname=gnome-software
pkgver=45.3
pkgrel=2
pkgdesc="Software lets you install and update applications and system extensions"
url="https://wiki.gnome.org/Apps/Software"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	appstream-dev
	flatpak-dev
	gdk-pixbuf-dev
	glib-dev
	gsettings-desktop-schemas-dev
	gtk4.0-dev
	gtk-doc
	json-glib-dev
	libadwaita-dev
	libgudev-dev
	libsoup3-dev
	libxmlb-dev
	meson
	ostree-dev
	polkit-dev
	"
options="!check" # lots of failing tests
install="$pkgname.post-upgrade"
subpackages="
	$pkgname-dbg
	$pkgname-lang
	$pkgname-doc
	$pkgname-dev
	$pkgname-lib
	$pkgname-plugin-flatpak:flatpak_plugin
	"
source="https://download.gnome.org/sources/gnome-software/${pkgver%.*}/gnome-software-$pkgver.tar.xz
	0002-disable-some-non-desired-preferences.patch
	appstream-no-python2.patch
	support-appstream-1.0.patch
	org.gnome.software.gschema.override
	"

case "$CARCH" in
	x86|x86_64|aarch64|armv7) makedepends="$makedepends fwupd-dev" ;;
esac

build() {
	case "$CARCH" in
		x86|x86_64|aarch64|armv7) conf="-Dfwupd=true" ;;
		*) conf="-Dfwupd=false" ;;
	esac

	abuild-meson \
		-Dmalcontent=false \
		-Dpackagekit=false \
		-Dhardcoded_proprietary_webapps=false \
		-Dtests=false \
		$conf \
		. output
	meson compile -C output
}

check() {
	meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
	install -Dm644 "$srcdir"/org.gnome.software.gschema.override \
		-t "$pkgdir"/usr/share/glib-2.0/schemas/
}

dev() {
	default_dev

	amove usr/lib/gnome-software/libgnomesoftware.so
}

lib() {
	pkgdesc="$pkgdesc (shared library)"
	depends=""

	amove usr/lib/gnome-software/libgnomesoftware.so.*
}

flatpak_plugin() {
	pkgdesc="$pkgdesc (flatpak plugin)"
	install_if="$pkgname=$pkgver-r$pkgrel flatpak"
	depends=""

	amove usr/lib/gnome-software/plugins-20/libgs_plugin_flatpak.so
	amove usr/share/metainfo/org.gnome.Software.Plugin.Flatpak.metainfo.xml
}
sha512sums="
45c8c92c9bd046b37b3fb4e817a0ea83fe9323d019f86140357f90bb2a0bf9dda5d33798c4b4d78303e2402c6cb603a4ff467e260e734b7ba97f07ebfaf4044c  gnome-software-45.3.tar.xz
3d35757225a7221d2a29c578c8f5281ce396729eda1811f8977079e67ba19bd0e656d1f4bb80f4dcde3a2a759991ea195267a6de1cf4729b07460c8f7c0c1aab  0002-disable-some-non-desired-preferences.patch
69c9dcefb05e59e33badeca212bf955a180e4a0bc2493c4ec319c7697b6bad23f5a6553302136c2db9f0d52ef49de01c1cae35c3bcbcbe60b17a2f79fc8b4af7  appstream-no-python2.patch
1dd58f8a38b6299bfc3c68b6b290081e8282a912363fa5196ec5ddd796f27c3271ac1fc9ca0348c495d8adc41c6c9a33b926c0eafbc00a0cf41900617f87b038  support-appstream-1.0.patch
fa82dfdaaa89554ae0882be6ed25ebcb48e7c9120c645401f369d1f888712002b2627900f629515136d66cf05dcb7d3a09d2bfd775c8063d3ec2d39c64cb1a5b  org.gnome.software.gschema.override
"
